/* Programme principal du moteur */

#include "optionServer.h"
#include <libsck.h>
#include <stdio.h>
#include <libthrd.h>
#include "workflow_struct.h"
#include "gestion_client.h"
#include <stdlib.h>
#include "gestion_admin.h"
#ifndef NULL
#define NULL   ((void *) 0)
#endif
void dummy(void *dialogue, void*(*action)(void *)){
	lanceClientLeger(dialogue,action);
}

int main(int argc, char *argv[])
{
	unsigned short int port=4000; /* port defaut */
	char * file=NULL;
	UserConnect=malloc(sizeof(struct tableUser));
	tableProcess=malloc(sizeof(struct tableProcess));
	UserConnect->nbUser=0;
	tableProcess->nbProcesses=0;
	if (analyse(argc,argv,&port,&file)==-1){
		display_option();
		exit(-1);
	}
	if (file!=NULL){
		fichierUsers=file;
	}
	if (init_verrous()!=0){
		perror("verrous");
		exit(-1);
	}
	dummy(NULL, gestionAdmin);
	int ecoute=initialisationServeur(&port);
	if (ecoute<0){
		perror("ecoute");
		exit(-1);
	}
	boucleServeur(ecoute, dummy, gestionClient);
	return 0;
}



